/***************************************************************************

-------------------
    begin                : 
    copyright            : kuzkok
    email                : kuzkok at gmail.com

***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*   
*   Данная программа является свободным программным обеспечением;         *
*   Вы можете распространять ее и/или модифицировать в соответствии с     *
*   GNU General Public License опубликованной Фондом свободного           *
*   программного обеспечения; используемая версия лицензии - 2 или        *
*   (по вашему выбору) любая более поздняя                                *
***************************************************************************/

#include "onlinepolylinefacility.h"

OnlinePolylineFacility::OnlinePolylineFacility(QString theTableName) :
        OnlineFacility(theTableName)
{
}

OnlinePolylineFacility::OnlinePolylineFacility(QUuid theEventID, QString theTableName) :
        OnlineFacility(theEventID, theTableName)
{
    if(mObjectState)
    {
        mBeginStation = mSelectQuery->value(mSelectQuery->record().indexOf("")).toDouble();
        mEndStation = mSelectQuery->value(mSelectQuery->record().indexOf("")).toDouble();
        mGroupEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("")).toString());
    }
}

void OnlinePolylineFacility::buildInsertStatement()
{
    OnlineFacility::buildInsertStatement();
    mInsertStatementFields += ", beginstation"
                             ", endstation"
                             ", groupeventid";
    mInsertStatementValues += ", :beginstation"
                             ", :endstation"
                             ", :groupeventid";
}

void OnlinePolylineFacility::buildUpdateStatement()
{
    OnlineFacility::buildUpdateStatement();
    mUpdateStatement += ", beginstation = :beginstation"
                       ", endstation = :endstation"
                       ", groupeventid = :groupeventid";
}

void OnlinePolylineFacility::bindQueryValues(QSqlQuery &query)
{
    OnlineFacility::bindQueryValues(query);
    query.bindValue(":beginstation", mBeginStation);
    query.bindValue(":endstation", mEndStation);
    query.bindValue(":groupeventid", UuidToVariant(mGroupEventID));
}
